package com.fzhucc.modules.pms.domain;

import com.fzhucc.base.BaseEntity;
import com.fzhucc.modules.expert.domain.Expert;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.Comment;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * @author Woolsen
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "pms_project_score")
public class ProjectScore extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(cascade = CascadeType.DETACH)
    @JoinColumn(name = "project_id")
    private Project project;

    @ManyToOne(cascade = CascadeType.DETACH)
    @JoinColumn(name = "expect_id")
    private Expert expert;

    private BigDecimal score;

    private Date scoreTime;

    @Column(name = "`advice`")
    @Comment(value = "建议")
    private String advice;

    @Column(name = "`project_level`")
    @ApiModelProperty(value = "分配专家评分时项目所处的项目等级阶段")
    private Integer projectLevel;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        ProjectScore that = (ProjectScore) o;
        return id != null && Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
